package com.base.monitor.model.enums.biz;

import cn.hutool.core.collection.CollectionUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum TandaFireControlMainEngineCodeEnum {
    FIRE_ALARM("1", "火警"),
    LOW_LIMIT_ALARM("2", "低限报警"),
    HIGH_LIMIT_ALARM("3", "高限报警"),
    OVER_RANGE_ALARM("4", "超量程报警"),
    RESIDUAL_CURRENT_ALARM("5", "剩余电流报警"),
    TEMPERATURE_ALARM("6", "温度报警"),
    ARC_ALARM("7", "电弧报警"),
    SMOKE_DETECTOR_ALARM("8", "感烟探测器报警"),
    TEMPERATURE_DETECTOR_ALARM("9", "感温探测器报警"),
    MANUAL_ALARM_BUTTON_ALARM("10", "手动报警按钮报警"),
    FIRE_DETECTOR_ALARM("11", "火焰探测器报警"),
    EARLY_WARNING("12", "预警"),
    FAULT("20", "故障"),
    COMMUNICATION_FAULT("21", "通讯故障"),
    MAIN_POWER_FAULT("22", "主电故障"),
    STANDBY_POWER_FAULT("23", "备电故障"),
    CIRCUIT_FAULT("24", "回路故障"),
    COMPONENT_FAULT("25", "部件故障"),
    START_LINE_FAULT("26", "启动线路故障"),
    SPRAY_LINE_FAULT("27", "喷洒线路故障"),
    FEEDBACK_LINE_FAULT("28", "反馈线路故障"),
    SPRAYING_FEEDBACK_CIRCUIT_FAULT("29", "喷洒反馈线路故障"),
    LAMP_FAULT("30", "灯具故障"),
    SELF_TEST("31", "自检"),
    BIT_FAIL("32", "自检失败"),
    COMMUNICATION_FAIL("33", "通讯失败"),
    FAILURE_RECOVERY("40", "故障恢复"),
    COMMUNICATION_FAILURE_RECOVERY("41", "通讯故障恢复"),
    MAIN_POWER_FAULT_RECOVERY("42", "主电故障恢复"),
    STANDBY_POWER_FAULT_RECOVERY("43", "备电故障恢复"),
    CIRCUIT_FAULT_RECOVERY("44", "回路故障恢复"),
    COMPONENT_FAULT_RECOVERY("45", "部件故障恢复"),
    START_LINE_FAULT_RECOVERY("46", "启动线路故障恢复"),
    SPRAY_LINE_FAULT_RECOVERY("47", "喷洒线路故障恢复"),
    FEEDBACK_LINE_FAULT_RECOVERY("48", "反馈线路故障恢复"),
    SPRAYING_FEEDBACK_CIRCUIT_FAULT_RECOVERY("49", "喷洒反馈线路故障恢复"),
    LAMP_FAULT_RECOVERY("50", "灯具故障恢复"),
    START("60", "启动"),
    AUTO_START("61", "自动启动"),
    MANUAL_START("62", "手动启动"),
    GAS_SPRAYING("63", "气体喷洒"),
    SCENE_URGENT_START("64", "现场急启"),
    STOP("70", "停止"),
    AUTOMATIC_STOP("71", "自动停止"),
    MANUAL_STOP("72", "手动停止"),
    SCENE_URGENT_STOP("73", "现场急停"),
    FEEDBACK("80", "反馈"),
    SPRAY_FEEDBACK("81", "喷洒反馈"),
    FEEDBACK_CANCELLATION("82", "反馈撤销"),
    SHIELD("83", "屏蔽"),
    SHIELD_CANCELLATION("84", "屏蔽撤销"),
    SUPERVISE("85", "监管"),
    SUPERVISE_CANCELLATION("86", "监管撤销"),
    GUIDE("90", "引导"),
    MEET_AN_EMERGENCY("91", "应急"),
    MONTHLY_INSPECTION("92", "月检"),
    YEARLY_INSPECTION("93", "年检"),
    CALL("100", "呼叫"),
    CONVERSATION("101", "通话"),
    OUTPUT_LINE_FAULT("128", "输出线故障"),
    OUTPUT_LINE_FAULT_RECOVERY("129", "输出线故障恢复"),
    INPUT_LINE_FAULT("130", "输入线故障"),
    INPUT_LINE_FAULT_RECOVERY("131", "输入线故障恢复"),
    BUS_SHORT_CIRCUIT("132", "总线短路"),
    BUS_SHORT_CIRCUIT_RECOVERY("133", "总线短路恢复"),
    NEW_REGISTRATION("134", "新注册"),
    SOUND_AND_LIGHT_ALARM_FAILURE("135", "声光警报器故障"),
    SOUND_AND_LIGHT_ALARM_FAILURE_RECOVERY("136", "声光警报器故障恢复"),
    FIRE_ALARM_TRANSMISSION_EQUIPMENT_FAILURE("137", "火警传输设备故障"),
    FIRE_ALARM_TRANSMISSION_EQUIPMENT_FAILURE_RECOVERY("138", "火警传输设备故障恢复"),
    DELAYED_START("139", "延时启动"),
    ;
    private String code;
    private String message;

    /**
     * 根据代码查找它的报警信息
     * @param code 报警代码
     * @return
     */
    public static String getMessage(String code) {
        List<TandaFireControlMainEngineCodeEnum> enums = new ArrayList<>(Arrays.asList(values()));
        List<TandaFireControlMainEngineCodeEnum> collect = enums.stream()
                .filter(item -> item.getCode().equals(code))
                .collect(Collectors.toList());
        if (CollectionUtil.isEmpty(collect)) {
            return "未知";
        }
        return collect.get(0).getMessage();
    }
}
